﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 观察者模式
{
    class Mouse
    {
        public string Color { get; set; }
        public string Name { get; set; }
        public Mouse() { }
        public Mouse(string color, string name, Cat cat)
        {
            Color = color;
            Name = name;
            // 把自身逃跑的方法注册到猫里面，订阅消息
            cat.action += RunAway;
        }
        public void RunAway()
        {
            Console.WriteLine(Color + "的" + Name + "说，老猫来了，我跑我跑我跑跑跑~");
        }
    }
}
